/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.materialMedia.degeneration;

import java.util.ArrayList;

import br.ufmg.dees.insane.analysisModel.AnalysisModel;
import br.ufmg.dees.insane.materialMedia.material.Material;
import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IVector;
import br.ufmg.dees.insane.util.geometricProperties.GeometricProperties;
import br.ufmg.dees.insane.util.geometricProperties.PrescribedGeometricProperties;

/**
*A class representing a cross section whose properties are given by the user.<p>
*
*@author Flavio, Roque, Samir, CENOURA!!!
*@version 1.0
*@since 20/09/2006
*/

public class PrescribedDegeneration extends Degeneration implements java.io.Serializable{
	
	private static final long serialVersionUID = 1L;
	
	/** The area of this Degeneration. */
	private double area = 0.0;
	
	/** The moment of inertia about the local X axis of this Degeneration.
	* It is also known as the torsional moment of the Degeneration.*/
	private double ix = 0.0;
	
	/** The moment of inertia about the local Y axis of this Degeneration.*/
	private double iy = 0.0;
	
	/** The moment of inertia about the local Z axis of this Degeneration.*/
	private double iz = 0.0;
	
	/** The height of the Degeneration.<p>
	* It's is initialized with the value 1 to avoid problems when calculating the equivalent nodal force for temperature changes.
	*/
	private double height = 1.0;
	
	/** The thickness of the Degeneration.<p>
	* It's is initialized with the value 1 to avoid problems when calculating the equivalent nodal force for temperature changes.
	*/
	private double thickness = 1.0;
	
	/** The form factor related to displament in y direction.<p>
	* If its value is 0, the shear deformations are ignored.
	*/
	private double formFactorY =0;
	
	/** The form factor related to displament in z direction.<p>
	* If its value is 0, the shear deformations are ignored.
	*/
	private double formFactorZ =0;
	
	/** The material of this Degeneration.*/
	private Material material;
	
	/** Returns the area of this Degeneration.
	*@return The area of this Degeneration.
	*/
	public double getArea()
	{
		return (area);
	}
	
	/** Sets the area of this Degeneration.
	*@param a The area of this Degeneration.
	*/
	public void setArea(double a)
	{
		area = a;
	}
	
	/** Returns the moment of inertia about the local X axis of this Degeneration.
	*@return The moment of inertia about the local X axis of this Degeneration.
	*/
	public double getIx()
	{
		return (ix);
	}
	
	/** Sets the moment of inertia about the local X axis of this Degeneration.
	*@param a The moment of inertia about the local X axis of this Degeneration.
	*/
	public void setIx(double a)
	{
		ix = a;
	}
	
	/** Returns the moment of inertia about the local Y axis of this Degeneration.
	*@return The moment of inertia about the local Y axis of this Degeneration.
	*/
	public double getIy()
	{
		return (iy);
	}
	
	/** Sets the moment of inertia about the local Y axis of this Degeneration.
	*@param a The moment of inertia about the local Y axis of this Degeneration.
	*/
	public void setIy(double a)
	{
		iy = a;
	}
	
	/** Returns the moment of inertia about the local Z axis of this Degeneration.
	*@return The moment of inertia about the local Z axis of this Degeneration.
	*/
	public double getIz()
	{
		return (iz);
	}
	
	/** Sets the moment of inertia about the local Z axis of this Degeneration.
	*@param a The moment of inertia about the local Z axis of this Degeneration.
	*/
	public void setIz(double a)
	{
		iz = a;
	}
	
	/** Returns the height of the Degeneration.
	*@return The height of the Degeneration.
	*/
	public double getHeight()
	{
		return (height);
	}
	
	/** Sets the height of the Degeneration.
	*@param a The height of the Degeneration.
	*/
	public void setHeight(double a)
	{
		height = a;
	}
	
	/** Returns the form factor related to displacement in y direction of the Degeneration.
	*@return The form factor related to displacement in y direction of the Degeneration.
	*/
	public double getFormFactorY()
	{
		return (formFactorY);
	}
	
	/** Sets the form factor related to displacement in y direction of the Degeneration.
	*@param a The form factor related to displacement in y direction of the Degeneration.
	*/
	public void setFormFactorY(double a)
	{
		formFactorY = a;
	}

	/** Returns the form factor related to displacement in z direction of the Degeneration.
	*@return The form factor related to displacement in z direction of the Degeneration.
	*/
	public double getFormFactorZ()
	{
		return (formFactorZ);
	}
	
	/** Sets the form factor related to displacement in z direction of the Degeneration.
	*@param a The form factor related to displacement in z direction of the Degeneration.
	*/
	public void setFormFactorZ(double a)
	{
		formFactorZ = a;
	}
	
	/** Returns the material of the Degeneration.
	*@return The material of the Degeneration.
	*/
	public Material getMaterial()
	{
		return (material);
	}
	
	/** Sets the material of the Degeneration.
	*@param a The material of the Degeneration.
	*/
	public void setMaterial(Material a)
	{
		material = a;
	}

	/** Returns the thickness of the Degeneration.
	 * @return
	 */
	public double getThickness() {
		return thickness;
	}

	/** Sets the thickness of the Degeneration.
	 * @param thickness
	 */
	public void setThickness(double thickness) {
		this.thickness = thickness;
	}
	
	/* (non-Javadoc)
	 * @see br.ufmg.dees.insane.materialMedia.degeneration.Degeneration#mountDualInternalVariableVector(br.ufmg.dees.insane.util.IVector)
	 */
	public IVector mountDualInternalVariableVector(IVector v) {
		 Representation repr = this.getRepresentation();
		 AnalysisModel am = repr.getAnalysisModel();
	 	IVector aux = repr.getCm().mountDualInternalVariableVector(v, am,this.getMaterial(), repr.getConstitutiveVariables());
	 	return am.modifyDualInternalVariableVector(aux, this.getGeometricProperties());
    }
 
	 /* (non-Javadoc)
	 * @see br.ufmg.dees.insane.materialMedia.degeneration.Degeneration#mountC()
	 */
	public IMatrix mountC(){
		 Representation repr = this.getRepresentation();
		 AnalysisModel am = repr.getAnalysisModel();
		 return am.modifyDualInternalVariableOperator(repr.getCm().mountC(am, this.getMaterial(), repr.getConstitutiveVariables()),this.getGeometricProperties());
	 }
	
	 /* (non-Javadoc)
	 * @see br.ufmg.dees.insane.materialMedia.degeneration.Degeneration#mountCs()
	 */
	public IMatrix mountCs(){
		 Representation repr = this.getRepresentation();
		 AnalysisModel am = repr.getAnalysisModel();
		 return am.modifyDualInternalVariableOperator(repr.getCm().mountCs(am, this.getMaterial(), repr.getConstitutiveVariables()),this.getGeometricProperties());
	 }
	 /* (non-Javadoc)
	 * @see br.ufmg.dees.insane.materialMedia.degeneration.Degeneration#mountCt()
	 */
	public IMatrix mountCt(){
		 Representation repr = this.getRepresentation();
		 AnalysisModel am = repr.getAnalysisModel();
		 return am.modifyDualInternalVariableOperator(repr.getCm().mountCt(am, this.getMaterial(), repr.getConstitutiveVariables()),this.getGeometricProperties());
	 }

	/* (non-Javadoc)
	 * @see br.ufmg.dees.insane.materialMedia.degeneration.Degeneration#modifyInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix)
	 */
	@Override
	public IMatrix internalVariableOperatorModifier(IMatrix B) {
		return this.getRepresentation().getAnalysisModel().modifyInternalVariableOperator(B,this.getMaterial().getPt());
	}
	
	 /* (non-Javadoc)
	 * @see br.ufmg.dees.insane.materialMedia.degeneration.Degeneration#getGeometricProperties()
	 */
	public GeometricProperties getGeometricProperties () {
			ArrayList<Double> properties = new ArrayList<Double>();
			properties.add(this.getArea());
			properties.add(this.getIx());
			properties.add(this.getIy());
			properties.add(this.getIz());
			properties.add(this.getThickness());
	        GeometricProperties gp = new PrescribedGeometricProperties(properties);
	        return gp;
	    }
	
    /* (non-Javadoc)
     * @see java.lang.Object#clone()
     */
    public Object clone() throws CloneNotSupportedException {
        PrescribedDegeneration pdg = new PrescribedDegeneration();
        pdg.label = this.label;
        pdg.originalLabel = this.originalLabel;
        pdg.representation = this.representation;
        pdg.materialPoints = this.materialPoints;
        pdg.area = this.area;
        pdg.formFactorY = this.formFactorY;
        pdg.formFactorZ = this.formFactorZ;
        pdg.height = this.height;
        pdg.ix = this.ix;
        pdg.iy = this.iy;
        pdg.iz = this.iz;
        pdg.label = this.label;
        pdg.material = this.material;
        pdg.thickness = this.thickness;
    	return pdg;
    }
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.materialMedia.degeneration.Degeneration#init()
     */
    public void init() {
    	Representation repr = this.getRepresentation();
    	repr.init();
    	repr.getCm().init(repr.getPreviousVariables(), repr.getConstitutiveVariables(), repr.getAnalysisModel(), this.getMaterial());
    }
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.materialMedia.degeneration.Degeneration#update()
     */
    public void update(){
    	Representation repr = this.getRepresentation();
    	repr.update();
        }
	
}